import { legacy_createStore, combineReducers, applyMiddleware } from 'redux'
import Numstatus_reducer from './Numstatus/reducer'
import Arrstatus_reducer from './Arrstatus/reducer'
import token_reducer from './token/reducer'
import { composeWithDevTools } from "redux-devtools-extension";
import { thunk } from 'redux-thunk'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
// 组合每个reducer
const reducers = combineReducers({
    Numstatus_reducer,
    Arrstatus_reducer,
    token_reducer
})

//在localStorge中生成key为root的值
const persistConfig = {
    key: 'token',
    storage,
    whitelist: ['token_reducer']  //设置某个reducer数据持久化
    // blacklist:['loading']  //设置某个reducer数据不持久化，
}
const myPersistReducer = persistReducer(persistConfig, reducers)


// 创建仓库
const store = legacy_createStore(myPersistReducer,
    composeWithDevTools(applyMiddleware(thunk))
)
export const persistor = persistStore(store);
export default store